home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
batteryi
/
form1.frm
(
.txt
)
< prev
next >
Wrap
Visual Basic Form
|
1999-06-18
|
7KB
|
219 lines
VERSION 5.00
Begin VB.Form frmBattery
BorderStyle = 1 'Fixed Single
Caption = "BatteryTest w/o the SysInfo.ocx"
ClientHeight = 2415
ClientLeft = 45
ClientTop = 330
ClientWidth = 4695
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2415
ScaleWidth = 4695
StartUpPosition = 1 'CenterOwner
Begin VB.PictureBox Picture1
BorderStyle = 0 'None
Height = 495
Left = 2050
Picture = "Form1.frx":030A
ScaleHeight = 495
ScaleWidth = 495
TabIndex = 10
Top = 845
Width = 495
End
Begin VB.Line Line1
Index = 6
X1 = 0
X2 = 4680
Y1 = 0
Y2 = 0
End
Begin VB.Line Line1
Index = 5
X1 = 2160
X2 = 4800
Y1 = 2400
Y2 = 2400
End
Begin VB.Line Line1
Index = 4
X1 = 0
X2 = 2640
Y1 = 2400
Y2 = 2400
End
Begin VB.Line Line1
Index = 3
X1 = 4680
X2 = 4680
Y1 = 0
Y2 = 2400
End
Begin VB.Line Line1
Index = 2
X1 = 0
X2 = 0
Y1 = 0
Y2 = 2400
End
Begin VB.Line Line1
Index = 1
X1 = 2640
X2 = 2640
Y1 = 0
Y2 = 2400
End
Begin VB.Line Line1
Index = 0
X1 = 2040
X2 = 2040
Y1 = 0
Y2 = 2400
End
Begin VB.Label Label10
Caption = "BatteryFlag"
Height = 255
Left = 120
TabIndex = 9
Top = 2040
Width = 1815
End
Begin VB.Label Label9
Caption = "ACLineStatus"
Height = 255
Left = 120
TabIndex = 8
Top = 1560
Width = 1815
End
Begin VB.Label Label8
Caption = "BatteryFullLifeTime"
Height = 255
Left = 120
TabIndex = 7
Top = 1080
Width = 1815
End
Begin VB.Label Label7
Caption = "BatteryLifeTime"
Height = 255
Left = 120
TabIndex = 6
Top = 600
Width = 1815
End
Begin VB.Label Label6
Caption = "BatteryLifePercent"
Height = 255
Left = 120
TabIndex = 5
Top = 120
Width = 1815
End
Begin VB.Label Label5
Caption = "Label5"
Height = 255
Left = 2760
TabIndex = 4
Top = 2040
Width = 1935
End
Begin VB.Label Label4
Caption = "Label4"
Height = 255
Left = 2760
TabIndex = 3
Top = 1560
Width = 1935
End
Begin VB.Label Label3
Caption = "Label3"
Height = 255
Left = 2760
TabIndex = 2
Top = 1080
Width = 1935
End
Begin VB.Label Label2
Caption = "Label2"
Height = 255
Left = 2760
TabIndex = 1
Top = 600
Width = 1935
End
Begin VB.Label Label1
Caption = "Label1"
Height = 255
Left = 2760
TabIndex = 0
Top = 120
Width = 1815
End
Attribute VB_Name = "frmBattery"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'------------------------------------------------------------
' SC Productions
' Name: RFN
' Company: SCP
' Purpose:To get information about the battery status
' with out having to use the SysInfo.ocx from MS
' Parameters: See Below
' Date: June,17 99
'------------------------------------------------------------
Option Explicit
Private Declare Function GetSystemPowerStatus Lib "kernel32" (lpSystemPowerStatus As SYSTEM_POWER_STATUS) As Long
Private Declare Function SetSystemPowerState Lib "kernel32" (ByVal fSuspend As Long, ByVal fForce As Long) As Long
Private Type SYSTEM_POWER_STATUS
ACLineStatus As Byte 'Checks to see if your connected to the walloutlet or not
BatteryFlag As Byte 'Battery status
BatteryLifePercent As Byte 'precentage left
Reserved1 As Byte 'Dont use
BatteryLifeTime As Long 'Total time left of your battery
BatteryFullLifeTime As Long 'Total UPtime of your battery
End Type
Private SysPower As SYSTEM_POWER_STATUS
'End Declares
Private Sub Form_Load()
'Property Get ACLineStatus() As Integer
'Returns a value that indicates whether or not the system is using AC power.
'Property Get BatteryFullLifeTime() As Long
'Returns a value that indicates the full charge life of the battery.
'Property Get BatteryLifePercent() As Integer
'Returns the percentage of full battery power remaining.
'Property Get BatteryLifeTime() As Long
'Returns a value that indicates the remaining life of the battery.
'Property Get BatteryFlag() As Integer
'Returns a value that indicates the status of the battery's charge.
GetSystemPowerStatus SysPower
Label1.Caption = Format$(SysPower.BatteryLifePercent / 100, "Percent")
Label2.Caption = Format$(Val(SysPower.BatteryLifeTime) * (1 / 3600), "##.0") & " Hours"
Label3.Caption = Format$(Val(SysPower.BatteryFullLifeTime) * (1 / 3600), "##.0")
'Label4.Caption = SysPower.ACLineStatus
If SysPower.ACLineStatus = 0 Then
Label4.Caption = "NON AC POWER"
ElseIf SysPower.ACLineStatus = 1 Then
Label4.Caption = "AC POWER"
ElseIf SysPower.ACLineStatus = 2 Then
Label4.Caption = "UNKNOWN AC POWER"
End If
'Label5.Caption = SysPower.BatteryFlag
If SysPower.BatteryFlag = 1 Then
Label5.Caption = "HIGH"
ElseIf SysPower.BatteryFlag = 2 Then
Label5.Caption = "LOW"
ElseIf SysPower.BatteryFlag = 4 Then
Label5.Caption = "CRITICAL"
ElseIf SysPower.BatteryFlag = 128 Then
Label5.Caption = "NO BATTERY"
ElseIf SysPower.BatteryFlag = 255 Then
Label5.Caption = "UNKNOWN"
End If
End Sub